package com.weiyuwqj.app.mobile.token;

import com.weiyuwqj.api.util.DateUtils;
import com.weiyuwqj.api.util.JwtUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;

/**
 * Created by zhangyong on 2016/4/7.
 */
@Controller
public class AuthorizeController {

    private static final String key="NWE2NTg4YzQtZTVmNy00NWVmLTlkOTAtMmJkYjhiNWIwY2Jl";

    @ResponseBody
    @RequestMapping("/mobile/appToken")
    public Object appToken(String uuid,String secretKey){
        HashMap<String,Object> map=new HashMap<String,Object>();
        Date d=new Date();
        d= DateUtils.addMonths(d, 1);
        if(key.equals(secretKey)){
            String token= JwtUtils.token(uuid, key, d);
            map.put("token",token);
        }else{
            map.put("result","error");
            map.put("message","secretKey error");
        }
        return map;
    }
}
